/* $Id: ToggleGridUnitTest.java 63 2010-02-14 13:52:34Z aaron.day $ */
package org.crazydays.gameplan.map.action;


import java.awt.event.ActionEvent;

import org.junit.*;
import static org.junit.Assert.*;

import static org.easymock.EasyMock.*;
import static org.easymock.classextension.EasyMock.*;

import org.crazydays.gameplan.controller.Controller;
import org.crazydays.gameplan.map.action.ToggleGrid;

/**
 * GridToggleUnitTest
 */
public class ToggleGridUnitTest
{
    /**
     * Test actionPerformed(ActionEvent).
     */
    @Test
    public void testActionPerformed_off()
    {
        // mocks
        Controller controller = createMock(Controller.class);
        ActionEvent event = createMock(ActionEvent.class);

        // setup
        ToggleGrid action = new ToggleGrid();
        action.setController(controller);

        // expect
        expect(controller.toggleGrid()).andReturn(false);

        // replay
        replay(controller, event);

        // test
        action.actionPerformed(event);

        // verify
        verify(controller, event);

        assertEquals("icon", ToggleGrid.tick, action
            .getValue(ToggleGrid.SMALL_ICON));
    }

    /**
     * Test actionPerformed(ActionEvent).
     */
    @Test
    public void testActionPerformed_on()
    {
        // mocks
        Controller controller = createMock(Controller.class);
        ActionEvent event = createMock(ActionEvent.class);

        // setup
        ToggleGrid action = new ToggleGrid();
        action.setController(controller);

        // expect
        expect(controller.toggleGrid()).andReturn(true);

        // replay
        replay(controller, event);

        // test
        action.actionPerformed(event);

        // verify
        verify(controller, event);

        assertEquals("icon", ToggleGrid.cross, action
            .getValue(ToggleGrid.SMALL_ICON));
    }
}
